package com.custom.windows;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.smartnsoft.fractory.R;

/**
 * The SaveProject Pop up.
 * 
 * @author Willy Noel
 * @since 2011.05.25
 */
public class SaveProjectPopup
    extends CustomPopupWindow
{

  private Context context;

  private LayoutInflater inflater;

  public Button saveProjectValidateButton;

  public Button saveProjectCancelButton;

  public TextView saveProjectNumber;

  public TextView saveProjectTitle;

  private View root;

  public EditText saveProjectEditText;

  public SaveProjectPopup(View anchor)
  {
    super(anchor);
    context = anchor.getContext();
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }

  public void setRootView(int ressources)
  {
    root = inflater.inflate(ressources, null);
    setContentView(root);

    saveProjectEditText = (EditText) root.findViewById(R.id.saveProjectEditText);
    saveProjectValidateButton = (Button) root.findViewById(R.id.okButtonsaveProject);
    saveProjectCancelButton = (Button) root.findViewById(R.id.cancelButtonsaveProject);
    saveProjectTitle = (TextView) root.findViewById(R.id.saveProjectText);
  }

  /**
   * Show popup window
   */
  public void show()
  {
    preShow();
    root.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    root.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    window.showAtLocation(this.anchor, Gravity.CENTER, 0, 0);
  }

}
